package com.lancoo.ccas52.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.lancoo.ccas52.config.MybatisRedisCache;
import com.lancoo.ccas52.entity.Room;
import com.lancoo.ccas52.pojo.dto.ArrangeRoomDto;
import com.lancoo.ccas52.pojo.dto.Building;
import com.lancoo.ccas52.pojo.vo.Campus;
import com.lancoo.ccas52.pojo.vo.RoomTypeDto;
import org.apache.ibatis.annotations.CacheNamespace;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Collection;
import java.util.List;

@CacheNamespace(implementation = MybatisRedisCache.class, eviction = MybatisRedisCache.class)
public interface RoomMapper extends BaseMapper<Room> {

    int addBatch(@Param("roomCollection") Collection<Room> roomCollection);

    List<RoomTypeDto> getRoomType(@Param("schoolId") String schoolId,@Param("term") String term);

    /**
     * 获取教室列表 排课所需字段
     * @param schoolId
     * @param term
     * @param campusId
     * @return
     */
    List<ArrangeRoomDto> getArrangeRoom(@Param("schoolId") String schoolId,@Param("term") String term,@Param("campusId") String campusId);

    List<Campus> getCampusList(@Param("schoolId") String schoolId ,@Param("term")String term);

    List<Building> getBuilding(@Param("schoolId") String schoolId,@Param("term") String term);

    /**
     * 获取楼层
     * @param taskId
     * @param buildingId
     * @return
     */
    List<Integer> getFloor(@Param("schoolId") String schoolId,@Param("term") String term,@Param("buildingId") Integer buildingId);

    /**
     * 获取教室列表 根据禁排来添加已设置未设置
     * @param page
     * @param schoolId
     * @param term
     * @param campusId
     * @param buildingId
     * @param buildingFloor
     * @param roomType
     * @param keyword
     * @param state
     * @return
     */
    IPage<Room> getRuleRoom(@Param("page") IPage page, @Param("schoolId") String schoolId, @Param("term") String term,
                            @Param("campusId") String campusId, @Param("buildingId") Integer buildingId, @Param("buildingFloor") Integer buildingFloor, @Param("roomType") Integer roomType, @Param("keyword") String keyword, @Param("state") Integer state, @Param("isEnable") Integer isEnable);

    @Select("select distinct room_type from room where school_id = #{schoolId} and term = #{term} " +
            "and is_enable = 1 and room_type is not null")
    List<Integer> getRoomTypeUsed(String schoolId, String term);
}